// function* gen() {
//     yield 1
//     yield 2
//     yield 3
//     return 4
// }

// const g = gen()

// console.log(g.next()); // { value: 1, done: false }
// console.log(g.next()); // { value: 2, done: false }
// console.log(g.next()); // { value: 3, done: false }
// console.log(g.next()); // { value: 4, done: true }


function fn(num) {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve(num)
        }, 1000)
    }) 
}

function* ge() {
    yield fn(1)
    yield fn(2)
    return 2
}

const g = ge()
const next1 = g.next()
next1.value.then(res => console.log(res))